[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 free()                  Deallocate Memory Block

 #include   <stdlib.h>                   Required for declarations only

 void       free(ptr);
 void       *ptr;                        Pointer to already allocated block

    free() deallocates the previously allocated memory block pointed to
    by 'ptr'.  The block must have been allocated by calloc() or malloc()
    and may have been reallocated or resized by realloc().  This makes
    the memory in the block available for reallocation.

       Returns:     There is no return value.

         Notes:     free() deallocates the number of bytes that were
                    allocated in the call to calloc(), malloc(), or
                    realloc().

   -------------------------------- Example ---------------------------------

    The following statements allocate space for 1000 bytes and then free
    the allocated space.

           #include <stdlib.h>     /* for free */
           #include <stdio.h>      /* for printf and NULL */

           char *memptr;

           main()
           {
               if ((memptr = malloc(1000)) == NULL)
                    printf("not enough room to allocate memory\n");
               else {
                    .
                    .
                    free(memptr);
                }
           }



See Also: malloc() calloc()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson